<?php

class Acl extends Zend_Acl
{
	public function  __construct()
	{	
		// Papeis = Role = Grupos*
		$this->addRole(new Zend_Acl_Role('guest')); // visitante
		$this->addRole(new Zend_Acl_Role('user')); // usuario logado no site
		$this->addRole(new Zend_Acl_Role('admin')); // admin
	
		// Recursos
		$this->add(new Zend_Acl_Resource('default:conta'));
		$this->add(new Zend_Acl_Resource('default:auth'));
		$this->add(new Zend_Acl_Resource('default:candidatos'));
		$this->add(new Zend_Acl_Resource('default:debates'));
		
		$this->add(new Zend_Acl_Resource('admin:auth'));
		$this->add(new Zend_Acl_Resource('admin:index'));
		$this->add(new Zend_Acl_Resource('admin:administrador'));
		$this->add(new Zend_Acl_Resource('admin:candidato'));
		$this->add(new Zend_Acl_Resource('admin:cargo'));
		$this->add(new Zend_Acl_Resource('admin:cidade'));
		$this->add(new Zend_Acl_Resource('admin:eleicao'));
		$this->add(new Zend_Acl_Resource('admin:estado'));
		$this->add(new Zend_Acl_Resource('admin:partido'));
		$this->add(new Zend_Acl_Resource('admin:politico'));
		$this->add(new Zend_Acl_Resource('admin:resultado'));
		$this->add(new Zend_Acl_Resource('admin:situacao'));
	
		// Privilegios
		$this->allow('guest', 'default:conta', 'cadastro');
		$this->allow('guest', 'admin:auth', 'index');
		$this->allow('guest', 'default:auth', 'index');
		$this->allow('guest', 'default:auth', 'forgotpassword');
	
		$this->allow('user', 'default:auth', 'logout');
		$this->allow('user', 'default:candidatos');
		$this->allow('user', 'default:debates');
		
		$this->allow('admin', 'admin:auth', 'logout');
		$this->allow('admin', 'admin:index');
		$this->allow('admin', 'admin:administrador');
		$this->allow('admin', 'admin:candidato');
		$this->allow('admin', 'admin:cargo');
		$this->allow('admin', 'admin:cidade');
		$this->allow('admin', 'admin:eleicao');
		$this->allow('admin', 'admin:estado');
		$this->allow('admin', 'admin:partido');
		$this->allow('admin', 'admin:politico');
		$this->allow('admin', 'admin:resultado');
		$this->allow('admin', 'admin:situacao');
		
// 		$this->deny('user', 'default:auth', 'index');
// 		$this->deny('user', 'default:conta', 'cadastro');
		
// 		$this->deny('admin', 'admin:auth', 'index');
	}
}

